/*
package com.qitmiaojie.security.service;

import com.qitmiaojie.pojo.Role;
import com.qitmiaojie.pojo.User;

import com.qitmiaojie.service.RoleService;
import com.qitmiaojie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

//@Service
public class MyUserService implements UserDetailsService {
    @Autowired
    private UserService userService;
    @Autowired
    private RoleService roleService;
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        User user = userService.getByUsername(username);
        if (user == null){
            throw new UsernameNotFoundException("用户不存在！");
        }
        //根据id 查询user对应的role
        List<Role> roles = roleService.getByUserId(user.getId());
        //如果role 不为空 查询该role 对应的权限

return null;
//
//        return new org.springframework.security.core.userdetails.User(user.getUsername(),user.getPassword(),list);
    }
}
*/
